package com.lfg.leetcode.leetcode300;


public class No392isSubsequence {
    public static void main(String[] args) {
        boolean ret2 = isSubsequence("abc", "ahbgdc");
        System.out.println(ret2);
    }

    public static boolean isSubsequence(String s, String t) {
        if (s == null || s.length() == 0) {
            return true;
        }
        if (t == null || t.length() == 0) {
            return false;
        }
        int index = 0;
        for (int i = 0; i < t.length(); i++) {
            if(index>=s.length()){
                return true;
            }
            if (t.charAt(i) == s.charAt(index)) {
                index++;
            }
        }
        return index >= s.length();
    }
}



